package scottb.flex;

import scottb.flex.event.FlexEvent;

import javax.swing.*;
import java.awt.*;

public class FlexPopUp extends Group {

    public FlexPopUp() {

        setOpaque(false);
        setBackground(new Color(100, 100, 100, 56));
    }

    public void close() {
        dispatchEvent(new FlexEvent(this, FlexEvent.CLOSE));
    }

    public FlexPopUp add(Component c) {
        super.add(c);
        return this;
    }

    public void paint(Graphics g) {

        Graphics2D g2 = (Graphics2D) g;
        Composite originalComposite = g2.getComposite();

        Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
        g2.setComposite(alphaComp);

        g2.fillRect(0, 0, getWidth(), getHeight());

        g2.setComposite(originalComposite);

        super.paint(g);
    }
}
